package edu.wit.common.api.factory;

import edu.wit.common.api.RemoteUserinfoService;
import edu.wit.common.api.model.LoginUser;
import edu.wit.common.core.domain.R;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 日志服务降级处理
 *
 * @author ruoyi
 */
@Component
public class RemoteUserinfoFallbackFactory implements FallbackFactory<RemoteUserinfoService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteUserinfoFallbackFactory.class);

    @Override
    public RemoteUserinfoService create(Throwable throwable) {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteUserinfoService() {
            @Override
            public Long getIdByUsername(String username) {
                return null;
            }

            @Override
            public R<LoginUser> getUserInfo(String username) {
                return null;
            }

            @Override
            public void updateLoginIp(LoginUser loginUser) {

            }


        };

    }
}
